package com.debao.web.controller.debao;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.debao.common.annotation.Log;
import com.debao.common.core.controller.BaseController;
import com.debao.common.core.domain.AjaxResult;
import com.debao.common.enums.BusinessType;
import com.debao.system.domain.Interest;
import com.debao.system.service.IInterestService;
import com.debao.common.utils.poi.ExcelUtil;
import com.debao.common.core.page.TableDataInfo;

/**
 * 关注Controller
 * 
 * @author DeBao
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/system/interest")
public class InterestController extends BaseController
{
    @Autowired
    private IInterestService interestService;

    /**
     * 查询关注列表
     */
    @PreAuthorize("@ss.hasPermi('system:interest:list')")
    @GetMapping("/list")
    public TableDataInfo list(Interest interest)
    {
        startPage();
        List<Interest> list = interestService.selectInterestList(interest);
        return getDataTable(list);
    }

    /**
     * 导出关注列表
     */
    @PreAuthorize("@ss.hasPermi('system:interest:export')")
    @Log(title = "关注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Interest interest)
    {
        List<Interest> list = interestService.selectInterestList(interest);
        ExcelUtil<Interest> util = new ExcelUtil<Interest>(Interest.class);
        util.exportExcel(response, list, "关注数据");
    }

    /**
     * 获取关注详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:interest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(interestService.selectInterestById(id));
    }

    /**
     * 新增关注
     */
    @PreAuthorize("@ss.hasPermi('system:interest:add')")
    @Log(title = "关注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Interest interest)
    {
        return toAjax(interestService.insertInterest(interest));
    }

    /**
     * 修改关注
     */
    @PreAuthorize("@ss.hasPermi('system:interest:edit')")
    @Log(title = "关注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Interest interest)
    {
        return toAjax(interestService.updateInterest(interest));
    }

    /**
     * 删除关注
     */
    @PreAuthorize("@ss.hasPermi('system:interest:remove')")
    @Log(title = "关注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(interestService.deleteInterestByIds(ids));
    }
}
